require("./searchResult.less");

var _article = require("service/article-service.js");
var _util = require("util/util.js");

var articleResult = require("./articleResult.string");

var page = {
	init : function(){
		this.loadSearchResut();
		this.bindEvent();
	},
	loadSearchResut : function(){
		var data = {
			title : _util.getUrlParam("keyword"),
			pageSize : 100
		}
		console.log(data.title);
		_article.getArticlelist(data,function(res){
			var articleResultHtml = _util.renderHtml(articleResult,res);
			$("#search-result").html(articleResultHtml);
		},function(err){
			console.log(err);
		})
	},
	bindEvent : function(){
		//搜索框点击
		$(document).on("click",".fa-search",function(){
			window.location.href = "./searchArticleResult.html?keyword="+$(this).siblings("input").val();
		});
	}
}

$(function(){
	page.init();
})